package com.soft.one;

import com.soft.one.db.MenuDb;
import com.soft.one.entity.Menu;
import com.soft.one.myprintf.MyPrintfs;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class MenuService {

    //已经选择菜品
    private static List<Menu> menuSelectList = new ArrayList<Menu>();

    public static List<Menu> getMenuSelectList() {
        return menuSelectList;
    }

    public static void setMenuSelectList(List<Menu> menuSelectList) {
        MenuService.menuSelectList = menuSelectList;
    }

    public static void foodSelect(){
        Map<String,Menu> menuMap = MenuDb.getMenuMap();
        List<Menu> menus = MenuDb.getMenuList();
        //打印菜单
        for (Menu menu : menus) {
            System.out.println("-------------------------------------------------");
            System.out.println("--------"+menu.getId()+":"+menu.getName() +":"+menu.getPrice() +"-------");
        }
        System.out.println("-------------------------------------------------");

        Scanner in = new Scanner(System.in);
        String select = in.nextLine();
        //选择菜单
        String[] foods = select.trim().split(" ");
        for (int i = 0; i < foods.length; i++) {
            Menu menu = menuMap.get(foods[i]);
            menuSelectList.add(menu);
        }
    }

    public static void selected(){
        System.out.println("*******************************************************");
        for (Menu menu : menuSelectList) {
            System.out.println("------"+menu.getName() +" : "+menu.getPrice() +"--------");
        }
        System.out.println("*******************************************************");

    }

}
